<template>
<view class="body">
  <view v-for="(item, idx) in allServer.allServer1" :key="idx" class="ser-list" v-if="item.nextServer[0]">
    <view class="title">
      <view class="ser-title-bef">
        <text>/</text>
        <text>/</text>
      </view>
      <text class="ser-name">{{item.ser_name}}</text>
      <view class="ser-title-aft">
        <text>/</text>
        <text>/</text>
      </view>
    </view>
    <view class="ser-sec-list">
      <view class="sec-item">
        <view v-for="(item, index) in item.nextServer" :key="index" class="sec" :data-index1="idx" :data-index2="index" hover-class="btn" @tap="feedBack2Next">
          <text>{{item.ser_name}}</text>
        </view>
      </view>
    </view>
  </view>
</view>
</template>

<script>
const app = getApp();
const util = require("../../../../utils/util.js");
var allServer = [];

export default {
  data() {
    return {
      allServer: [] // 一级二级目录

    };
  },

  components: {},
  props: {},
  onLoad: function () {
    this.init();
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    return {
      imageUrl: "http://imgbdb3.bendibao.com/xcxbdb/file/20212/9/20210209161843_68677.jpg"
    };
  },
  methods: {
    init() {
      let $feedBackAllServer = {
        ac: "allServer",
        city: "sz",
        type: app.globalData.platform
      };
      util.getUrl(app.globalData.url).then(res => {
        util.bstrequest('index.php', $feedBackAllServer, "POST").then(res => {
          allServer = JSON.parse(JSON.stringify(res.data));

          if (allServer.allServer1) {
            allServer.allServer1.forEach(v => {
              if (this.getNextServer(v.id)) v.nextServer = this.getNextServer(v.id);
            });
            this.setData({
              allServer
            });
          }
        });
      });
    },

    getNextServer(pid) {
      let nextServer = [];
      nextServer = allServer.allServer2.filter(v => v.pid == pid);
      return nextServer;
    },

    feedBack2Next(e) {
      let index1 = e.currentTarget.dataset.index1;
      let index2 = e.currentTarget.dataset.index2;
      let data = this.allServer.allServer1[index1].nextServer[index2];

      if (data.id === '2885') {
        uni.navigateTo({
          url: `index/index`
        });
        util.clickNumber(data.id);
      }

      if (data.id === '2973') {
        uni.navigateTo({
          url: `shebao/shebao`
        });
        util.clickNumber(data.id);
      }

      if (data.id === '2987') {
        uni.navigateTo({
          url: 'listQuery/listQuery'
        });
      }

      if (data.ser_name == '天气预报') {
        uni.navigateTo({
          url: 'weather/weather'
        });
        util.clickNumber(data.id, 1);
      }

      if (data.ser_link_method != "0") {
        util.click2NextProgram(data);
        util.clickNumber(data.id);
      }
    }

  }
};
</script>
<style>
/* pages/order/Feedback.wxss */
.body {
    padding: 30rpx 40rpx;
}
.ser-list {
    display: flex;
    flex-direction: column;
    align-items: center;
    background:rgba(255,255,255,1);
    box-shadow:0 0 12rpx rgba(0,0,0,0.16);
    opacity:1;
    border-radius:16rpx;
    padding: 34rpx 46rpx;
    margin-bottom: 30rpx;
}
.title {
    display: flex;
    align-items: center;
    margin-bottom: 40rpx;
    font-size: 48rpx;
}
.ser-title-bef, .ser-title-aft {
    font-size: 28rpx;
    font-weight: bold;
}
.ser-title-bef text:last-child{
    color: #ff6600;
}
.ser-title-bef text:first-child{
    color: #FFAA00;
}
.ser-title-aft text:first-child{
    color: #ff6600;
}
.ser-title-aft text:last-child{
    color: #FFAA00;
}
.ser-name {
    margin: 0 16rpx;
}
.sec-item {
    display: flex;
    flex-wrap: wrap;
    width: 109%;
    box-sizing: border-box;
    color: #232323;
}
.sec {
    width: 30%;
    /*border-left: 2rpx solid #C2C2C2;*/
    /*padding-left: 16rpx;*/
    padding-bottom: 42rpx;
    font-size: 32rpx;
    height: 40rpx;
    line-height: 40rpx;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sec text {
    border-left: 2rpx solid #C2C2C2;
    padding-left: 16rpx;
}
.ser-sec-list {
    width: 100%;
}
button {
    padding: 0;
    margin: 0;
    border-radius: 0;
}

</style>